home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / Technical Documentation / develop / develop Issue 23 / develop Issue 23 code / ProjectDrag 1.1b8 / Sources / ProjectDrag Sources / Obsolete.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-12  |  2.6 KB  |  117 lines  |  [TEXT/MPS ]

  1. /* Obsolete.c: Obsolete applet for ProjectDrag
  2.  *
  3.  * A set of applets for drag and drop source control by Tim Maroney.
  4.  * See develop, issue 23 for details.
  5.  *
  6.  * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
  7.  * and using the MoreFiles utilities by Jim Luther.
  8.  *
  9.  * This software is free, but don't modify and redistribute it without
  10.  * changing the status window to indicate your name and your changes!
  11.  */
  12.  
  13.  
  14. #include <Errors.h>
  15.  
  16. #include "DSUserProcs.h"
  17. #include "SourceServer.h"
  18. #include "PDDialogs.h"
  19. #include "TasksAndErrors.h"
  20.  
  21.  
  22. void ObsoleteFile(FSSpec *file);
  23.  
  24.  
  25. /* This routine is called for each file passed in the ODOC event. */
  26.  
  27. pascal void OpenDoc ( FSSpecPtr myFSSPtr, Boolean opening, Handle userDataHandle )
  28. {
  29. #pragma unused ( opening )
  30. #pragma unused ( userDataHandle )
  31.  
  32.     ObsoleteFile(myFSSPtr);
  33. }
  34.  
  35.  
  36. void ObsoleteFile(FSSpec *file)
  37. {
  38.     Str63 userName;
  39.     Str15 nickname;
  40.     AEDesc command;
  41.     Str255 projectName;
  42.     OSErr err;
  43.     CKIDHandle theCKID;
  44.     
  45.     TaskStart(2001, 1, file->name, NULL, NULL, NULL);
  46.     
  47.     /* confirm the obsoletion */
  48.     if (!ResTextYesNo(2002, 1, file->name, NULL, NULL, NULL))
  49.     {
  50.         RaiseErrorNumber(userCanceledErr);
  51.         return;
  52.     }
  53.     
  54.     /* find the user name and initials */
  55.     err = GetUserSettings(userName, nickname, false);
  56.     if (err != noErr)
  57.     {
  58.         gDone = true;
  59.         return;
  60.     }
  61.  
  62.     /* get the CKID */
  63.     err = ExtractCKID(file, &theCKID);
  64.     if (err != noErr)
  65.     {
  66.         RaiseErrorString(kProjectDragStrings, kCantGetCKID, file->name,
  67.                          NULL, NULL, NULL);
  68.         return;
  69.     }
  70.     
  71.     /* Make sure the file is checked in. */
  72.     if ((*theCKID)->writeable || (*theCKID)->modifyReadOnly)
  73.     {
  74.         DisposeHandle((Handle)theCKID);
  75.         RaiseErrorString(2002, 2, file->name, NULL, NULL, NULL);
  76.         return;
  77.     }
  78.     
  79.     /* mount the project */
  80.     err = MountProjectFromCKID(theCKID, projectName);
  81.     DisposeHandle((Handle)theCKID);
  82.     if (err != noErr) return;
  83.     
  84.     /* create an ObsoleteProjectorFile command for SourceServer
  85.      * ObsoleteProjectorFile -project <project> -u <user> <file>
  86.      */
  87.     err = CreateCommand(&command, "ObsoleteProjectorFile");
  88.     if (err == noErr)
  89.         err = AddProjectArg(&command, projectName);
  90.     if (err == noErr)
  91.         err = AddUserArg(&command, userName);
  92.     if (err == noErr)
  93.         err = AddPStringArg(&command, file->name);
  94.     if (err != noErr)
  95.     {
  96.         AEDisposeDesc(&command);
  97.         RaiseErrorNumber(err);
  98.         return;
  99.     }
  100.     
  101.     err = SendCommand(&command);        /* send the command to SourceServer */
  102.     if (err != noErr) return;
  103.     
  104.     err = FSpDelete(file);                /* don't worry about delete failures */
  105.  
  106.     TaskDone();
  107. }
  108.  
  109.  
  110. void DoFileMenu(short itemID)
  111. {
  112.     if ( itemID == 1 )
  113.         SelectFile();        // call file selection userProc
  114.     else
  115.         SendQuitToSelf();    // send self a 'quit' event
  116. }
  117.